package com.xuecheng.content.api;


import com.spring4all.swagger.EnableSwagger2Doc;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 */
@Api(value = "课程教师管理接口",tags = "课程教师管理接口")
@EnableSwagger2Doc
@RestController//相当于Controller 和 RequestBody 结合
public class CourseTeacherController {
    @Autowired
    CourseTeacherService courseTeacherService;


    @ApiOperation("课程教师查询接口")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> list(@PathVariable Long courseId){
        return  courseTeacherService.getTeacherInfo(courseId)  ;
    }

    @ApiOperation("新增或修改教师接口")
    @PostMapping("/courseTeacher")
    public CourseTeacher createAndUpdateCourseTeacher(@RequestBody CourseTeacher courseTeacher){
        Long companyId=1232141425L;
        return  courseTeacherService.addAndUpdateCourseTeacher(courseTeacher,companyId)  ;
    }
    @ApiOperation("删除教师接口")
    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    public void deleteCourseTeacher(@PathVariable("courseId") Long courseId,@PathVariable("id") Long id){
        Long companyId=1232141425L;
        courseTeacherService.removeCourseTeacher(courseId,id,companyId);
    }

}
